package com.kinyx.framework.db.dialect;

import java.util.List;

import com.kinyx.framework.db.sentence.str.SQL;

public class MySQL extends Dialect {

	@Override
	public boolean checkDriverClassName(final String driverClassName) {
		return "com.mysql.jdbc.Driver".equals(driverClassName) || "com.mysql.cj.jdbc.Driver".equals(driverClassName);
	}

	@Override
	public SQL createPageSQL(final String sql, final List<Object> params, int pageNumber, int pageSize) {
		// 参数修正
		if (pageNumber < 0) { pageNumber = 0; }
		if (pageSize <= 0) { pageSize = com.kinyx.framework.Configs.default_pageSize; }
		// 拼接
		return new SQL().addAll(params).s(sql).s(" LIMIT ?, ?").p(pageNumber * pageSize).p(pageSize);
	}

}
